Skip to main content

How to organize and visualize spending in Beancount

·

By labeling financial transactions with categories in Beancount, the tool automatically calculates the subtotals of each category, from which fava generates useful visualizations.

These categories are called accounts in Beancount. Accounts can have sub-accounts. For example:

Expenses:Food:Grocery
Expenses:Food:Restaurant

Here Grocery account is a child or sub-account of Food, which is a child or sub-account of Expenses. The subtotal of a parent is sum of local transactions and sum of all subtotals of its children. For example, the subtotal of Expenses:Food:Grocery is sum of all transactions labeled so. And similarly for the subtotal of Expenses:Food:Restaurant. Then the subtotal of Expenses:Food is sum of all transactions labeled so and its children’s subtotal. This rule repeats all the way up the account hierarchy.

With such account hierarchy, the fava GUI for Beancount can generate informative plots such as a sunburst plot:

sunburst

The outer ring are sub-accounts of the inner ring.

Or a treemap:

treemap

Or stacked bars over time:

stacked-bars

The financial data above is an example generated by Beancount.

For me, I organize my expenses into the following major accounts and they are further split into more sub-accounts. My major accounts are:

  • Education
  • Food
  • Home
  • Financial
  • Insurance
  • Health
  • Shopping
  • Services
  • Travel
  • Unknown

Actual Beancount code:

1970-01-01 open Expenses:Education:Books
1970-01-01 open Expenses:Education:Classes
1970-01-01 open Expenses:Education:Tuition
1970-01-01 open Expenses:Food:Grocery
1970-01-01 open Expenses:Food:ConvenienceStore
1970-01-01 open Expenses:Food:Restaurant
1970-01-01 open Expenses:Home:Electricity
1970-01-01 open Expenses:Home:Gas
1970-01-01 open Expenses:Home:Insurance
1970-01-01 open Expenses:Home:Internet
1970-01-01 open Expenses:Home:Misc
1970-01-01 open Expenses:Home:Water
1970-01-01 open Expenses:Financial:Commissions
1970-01-01 open Expenses:Financial:Fees
1970-01-01 open Expenses:Financial:Fees:ATM
1970-01-01 open Expenses:Financial:Fees:BankTransfer
1970-01-01 open Expenses:Financial:WireTransfer
1970-01-01 open Expenses:Insurance:Auto
1970-01-01 open Expenses:Insurance:Medical
1970-01-01 open Expenses:Insurance:Life
1970-01-01 open Expenses:Health:Dental
1970-01-01 open Expenses:Health:Medicine
1970-01-01 open Expenses:Health:Therapy
1970-01-01 open Expenses:Health:Vision
1970-01-01 open Expenses:Health:VisitCopay
1970-01-01 open Expenses:Shopping:Children
1970-01-01 open Expenses:Shopping:Clothing
1970-01-01 open Expenses:Shopping:Cycling
1970-01-01 open Expenses:Shopping:Donation
1970-01-01 open Expenses:Shopping:Farming
1970-01-01 open Expenses:Shopping:Gift
1970-01-01 open Expenses:Shopping:Household
1970-01-01 open Expenses:Shopping:Outdoor
1970-01-01 open Expenses:Shopping:Photography
1970-01-01 open Expenses:Shopping:Stationary
1970-01-01 open Expenses:Shopping:Technology
1970-01-01 open Expenses:Shopping:Toy
1970-01-01 open Expenses:Shopping:Wellness
; Recurring transactions
1970-01-01 open Expenses:Services:Car
1970-01-01 open Expenses:Services:Computing
1970-01-01 open Expenses:Services:Telecom
1970-01-01 open Expenses:Transport:Bus
1970-01-01 open Expenses:Transport:Ferry
1970-01-01 open Expenses:Transport:Flight
1970-01-01 open Expenses:Transport:Gasoline
1970-01-01 open Expenses:Transport:Parking
1970-01-01 open Expenses:Transport:Taxi
1970-01-01 open Expenses:Transport:Toll
1970-01-01 open Expenses:Transport:Train
1970-01-01 open Expenses:Travel:Fun
1970-01-01 open Expenses:Travel:Food
1970-01-01 open Expenses:Travel:Souvenir
1970-01-01 open Expenses:Travel:Misc
1970-01-01 open Expenses:Travel:Sleep
1970-01-01 open Expenses:Travel:Spiritual
; Transactions on marketplaces
1970-01-01 open Expenses:Unknown:Amazon
1970-01-01 open Expenses:Unknown:Apple
1970-01-01 open Expenses:Unknown:Google
1970-01-01 open Expenses:Unknown:Wallet
view raw expenses.bean hosted with ❤ by GitHub